#include <stdio.h>
#include <unistd.h>
#include <sys/epoll.h>

int main()
{
    int epfd = epoll_create(6);
    if(epfd < 0)
    {
        perror("epoll_create");
        return 0;
    }

    struct epoll_event ee;
    ee.events = EPOLLIN;
    ee.data.fd = 0;

    epoll_ctl(epfd, EPOLL_CTL_ADD, 0, &ee);

    int count = 0;
    while(1)
    {
        struct epoll_event arr[10];
        int ret = epoll_wait(epfd, arr, 10, 0);
        if(ret < 0)
        {
            perror("epoll_wait");
            return 0;
        }
        else if(ret == 0)
        {
            continue;
        }

            char buf[2] = {0};
            read(arr[0].data.fd, buf, sizeof(buf) - 1);
            printf("buf is:%s\n", buf);
            printf("%d\n", count++);
    }
    return 0;
}
